function category_sort(_rows){
	
	var row, list = [], row_pk, result = [];
	for(var i=0, len=_rows.length; i<len; i+=1){
		
		row =_rows[i];

		if(row["grade"] == 1){

			list[row["seq"]] = row;	//一维数组存放一级分类
			row_pk = "pk_" + row["id"];
			if(!list[row_pk]) list[row_pk] = [];	//数组属性存放二级分类

		} else if(row["grade"] == 2){

			var row_pk = "pk_" + row["parent_id"];
			if(!list[row_pk]){	//上级分类未被遍历，先添加下级分类
				list[row_pk] = [];
			}
			list[row_pk].push(row);
			
		}
	}

	for(var i=0, len=list.length; i<len; i+=1){

		if(list[i]){
			result.push(list[i]);
			row_pk = "pk_" + list[i]["id"];
			list[row_pk].sort(function(row1, row2){
				if(row1["seq"] > row2["seq"]) return 1;
				else return -1;
			})
			result = result.concat(list[row_pk]);
		}
	}
	return result;
}